package com.snail.billing.os;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.android.os.IPage;
import com.android.os.IPageManager;

public class DialogPage implements IPage {

	private DialogPageActivity manager;
	private Bundle args;
	private View layout;

	public View onCreateView() {
		layout = LayoutInflater.from(getContext()).inflate(createLayoutId(), null);
		return layout;
	}

	public ViewGroup.LayoutParams getLayoutParams() {
		int orientation = getContext().getResources().getConfiguration().orientation;
		int screenWidth = getContext().getResources().getDisplayMetrics().widthPixels;
		int screenHeight = getContext().getResources().getDisplayMetrics().heightPixels;
		if (orientation == Configuration.ORIENTATION_PORTRAIT) {
			int width = (int) (screenWidth * 0.9);
			int height = (int) (screenHeight * 0.8 * 9 / 16);
			return new ViewGroup.LayoutParams(width, height);
		} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
			int width = (int) (screenWidth * 0.8);
			int height = (int) (screenWidth * 0.8 * 9 / 16);
			return new ViewGroup.LayoutParams(width, height);
		}
		return new ViewGroup.LayoutParams(screenWidth, screenHeight);
	}

	public void onCreate(Bundle savedInstanceState) {
	}

	public void onRestart() {
	}

	public void onStart() {
	}

	public void onResume() {
	}

	public void onPause() {
	}

	public void onStop() {
	}

	public void onDestroy() {
	}

	public void onActivityResult(int requestCode, int resultCode, Intent data) {
	}

	public void onSaveInstanceState(Bundle outState) {
	}

	public void onConfigurationChanged(Configuration config) {
	}

	@Override
	public int createLayoutId() {
		return 0;
	}

	@Override
	public DialogPageActivity getPageManager() {
		return manager;
	}

	@Override
	public void setPageManager(IPageManager manager) {
		this.manager = (DialogPageActivity) manager;
	}

	@Override
	public View findViewById(int id) {
		return layout.findViewById(id);
	}

	@Override
	public Context getContext() {
		return manager;
	}

	@Override
	public Bundle getPageArgs() {
		return args;
	}

	@Override
	public void setPageArgs(Bundle args) {
		this.args = args;
	}

}
